package com.jcark.mvvm.net

import android.view.View
import androidx.databinding.ObservableInt
import me.hgj.mvvm.base.viewmodel.BaseViewModel
import me.hgj.mvvm.callback.databind.BooleanObservableField
import me.hgj.mvvm.callback.databind.StringObservableField

class LoginRegisterViewModel : BaseViewModel() {

    //手机号
    var mobile = StringObservableField()

    //密码
    var password = StringObservableField()

    var isShowPwd = BooleanObservableField()

    var clearVisible = object :ObservableInt(mobile) {
        override fun get(): Int {
            return if(mobile.get().isEmpty()){
                View.GONE
            } else {
                View.VISIBLE
            }
        }
    }

    //密码显示按钮是否显示   不要在 xml 中写逻辑 所以逻辑判断放在这里
    var passwordVisible = object :ObservableInt(password){
        override fun get(): Int {
            return if(password.get().isEmpty()){
                View.GONE
            }else{
                View.VISIBLE
            }
        }
    }
}
